<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\BaseController;
use Illuminate\Http\Request;

/**
 * @package App\Http\Controllers\Api
 * @see SearchController
 */
class SearchController extends BaseController
{

    /**
     * article
     * @uri /search/article
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     * @request {"keywords_article":"93C217C6F853F7E8","last_id":"AF7F6363952FE762"}
     * @response {"success":true,"statusCode":200,"result":{"have_more":false,"list":[{"id":"00KHZ79WZYNM3ISK8HMNO6TP","cover_url":"","title":"\u6587\u7ae0\u6807\u9898","description":"\u6587\u7ae0\u63cf\u8ff0","is_deleted":0,"is_shield":0,"created_at":1606417117,"original":{"author_name":"\u9ea6\u5927\u4eba","from":7,"time":1597498069},"count":{"collect":2,"note":1}}]},"message":"OK"}
     */
    public function article(Request $request)
    {
        $params = $request->all();

        // @todo api data from mock.
        $mock = json_decode(
            mb_convert_encoding(
                '{"success":true,"statusCode":200,"result":{"have_more":false,"list":[{"id":"00KHZ79WZYNM3ISK8HMNO6TP","cover_url":"","title":"\u6587\u7ae0\u6807\u9898","description":"\u6587\u7ae0\u63cf\u8ff0","is_deleted":0,"is_shield":0,"created_at":1606417117,"original":{"author_name":"\u9ea6\u5927\u4eba","from":7,"time":1597498069},"count":{"collect":2,"note":1}}]},"message":"OK"}'
                , 'UTF-8', 'UTF-8,GBK,GB2312,BIG5' )
            , true
        );
        $data = $mock['result'];

        return $this->apiReturn($data);
    }

    /**
     * user
     * @uri /search/user
     * @param Request $request
     * @return \Illuminate\Http\JsonResponse
     * @request {"keywords_user":"8C101FD2C65F581D","last_id":"FBEA1D2D991A6E05"}
     * @response {"success":true,"statusCode":200,"result":{"have_more":false,"list":[{"id":"00K5M5AQKM1YGHAQ11F4DVJZ","nickname":"\u9648\u80fd","avatar":"d3c829ef6cf628f0b8f39184eda76d75.png","special_signature":"\u9762\u5bf9\u73b0\u5b9e\uff0c\u6781\u5ea6\u5f00\u653e\uff0c\u4e0e\u4eba\u4e3a\u5584\uff0c\u4e0d\u4e22\u6389\u521d\u5fc3\u548c\u81ea\u5df1\uff01"}]},"message":"OK"}
     */
    public function user(Request $request)
    {
        $params = $request->all();

        // @todo api data from mock.
        $mock = json_decode(
            mb_convert_encoding(
                '{"success":true,"statusCode":200,"result":{"have_more":false,"list":[{"id":"00K5M5AQKM1YGHAQ11F4DVJZ","nickname":"\u9648\u80fd","avatar":"d3c829ef6cf628f0b8f39184eda76d75.png","special_signature":"\u9762\u5bf9\u73b0\u5b9e\uff0c\u6781\u5ea6\u5f00\u653e\uff0c\u4e0e\u4eba\u4e3a\u5584\uff0c\u4e0d\u4e22\u6389\u521d\u5fc3\u548c\u81ea\u5df1\uff01"}]},"message":"OK"}'
                , 'UTF-8', 'UTF-8,GBK,GB2312,BIG5' )
            , true
        );
        $data = $mock['result'];

        return $this->apiReturn($data);
    }

}